package com.siwei.mes.mapper.experiment;

import com.siwei.mes.common.base.BaseMapper;
import com.siwei.mes.entity.experiment.ExperimentWaybill;
import com.siwei.mes.entity.sync.tc.Waybill;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * 试验台账与运单关系(ExperimentWaybill)表数据库访问层
 *
 * @author makejava
 * @since 2024-05-27 21:37:50
 */
public interface ExperimentWaybillMapper extends BaseMapper<ExperimentWaybill> {
    /**
     * 获取所有
     *
     * @param entity
     * @return
     */
    List<ExperimentWaybill> getList(ExperimentWaybill entity);

    List<Waybill> selectByExperimentId(@Param("experimentId") Long experimentId);

    List<Waybill> selectByExperimentIdAndTask(@Param("experimentId") Long experimentId, Long supplyTaskId);

    int selectWaybillIdById(@Param("waybillId") Long experimentId, @Param("checkType") Integer checkType);

    Double selectByrealMaterialNumberByExperimentId(@Param("experimentId") Long experimentId);

    /**
     * 获取代表数量
     *
     * @param supplyTaskId 任务单id
     * @param experimentId 实验台账id
     * @return
     */
    BigDecimal selectByBehalfNumber(@Param("supplyTaskId") Long supplyTaskId, @Param("experimentId") Long experimentId);

    /**
     * 根据试验委托id删除
     *
     * @param experimentId 试验委托id
     */
    void deleteByExperimentId(@Param("experimentId") Long experimentId);

    /**
     * 根据试验委托id和运单id删除
     *
     * @param experimentId 试验委托id
     * @param waybillId    运单id
     */
    void deleteByExperimentIdAndWaybillId(@Param("experimentId") Long experimentId, @Param("waybillId") Long waybillId);

    /**
     * 查询对应试验委托的累计方量
     *
     * @param experimentId
     * @return
     */
    Double selectTotalBehalfNumberByExperimentId(@Param("experimentId") Long experimentId);
}
